<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="yongjian.drp.model.User" %>
<%@ taglib uri="/struts-tags" prefix="s" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

User recorder = (User)session.getAttribute("user");
String name = recorder.getUsername();
int id = recorder.getId();
String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'user_add.jsp' starting page</title>
    
    <link rel="stylesheet" type="text/css" href="js/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="js/themes/icon.css">
    <script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="js/locale/easyui-lang-zh_CN.js"></script>
    
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript">
		$(function(){				
			 $('#grid').datagrid({   
			  	  idField:'id',
			  	  title:'流向单复审表',
			      url:'json/flowCard_list.action?vouSts=F&spotFlag=Y', 
			      striped:true,
			      loadMsg:'正在加载中，请等待....',
			      pagination:true,
			      fitColumns:true,
			      rownumbers:true,
			      pageSize:7,
			      pageList:[7,14,21,28,35],
			      
			      frozenColumns:[
									[{
										field:'cb',
										checkbox:true									
									 }]				               
					               ],
			      columns:[[   
			          {field:'id',title:'流向单号',width:100},   
			          {field:'clientId',title:'供方分销商代码',width:100},   
			          {field:'clientName',title:'供方分销商名称',width:100}, 
			          {field:'vouSts',title:'审核状态',width:100,formatter:function(value){
			        	  if(value == 'F'){
			        		  return '审核完成';
			        	  } else {
			        		  return '审核未通过';
			        	  }
			          }},
			          {field:'spotFlag',title:'抽查状态',width:100,formatter:function(value){
			        	  if(value == 'Y'){
			        		  return '已抽查';
			        	  } else {
			        		  return '没抽查';
			        	  }
			          }},
			          {field:'recorder',title:'录入人',width:100},  
			          {field:'recordTime',title:'录入时间',width:100,formatter:function(value){
			        	  return value.replace("T","  ");
			          }},
			      ]] ,
			      toolbar:[{
						text:'复审通过' ,
						iconCls:'icon-ok' , 
						handler:function(){														
							var arr = $('#grid').datagrid('getSelections');							
							if(arr.length == 1){
								$('#dialog').dialog({
									title:'复审确认' ,
								});
								$('#dialog').dialog('open');
								document.getElementById("confirmerId").value=<%=id%>;
								document.getElementById("flowCardId").value=arr[0].id;
								document.getElementById("confirmerName").value=<%=name%>;
								document.getElementById("confFlag").value='Y';
							} else {
								$.messager.alert('提示','请选择一条记录操作');
							}														
						}							
					},{
						text:'驳回' ,
						iconCls:'icon-undo' , 
						handler:function(){														
							var arr = $('#grid').datagrid('getSelections');							
							if(arr.length == 1){
								$.messager.confirm('提示','要驳回吗？',function(r){
									if(r){
										$.post('json/flowCard_modify.action',{
											"flowCard.id":arr[0].id,
											"flowCard.vouSts":'N',
											"flowCard.spotFlag":'N',
											"flowCard.confFlag":'N'},
											function(){
												$('#grid').datagrid('reload');
												$.messager.show({
													title:'提示',
													msg:'操作成功'
											});
										});
									}
								});
							} else {
								$.messager.alert('提示','请选择一条记录操作');
							}														
						}							
					}]
			  });
			
			$('#save').click(function(){
			    $('#myform').form('submit', {   
				        url:'json/flowCard_modify.action', 
				        onSubmit: function(){  
				        	if(!$('#myform').form('validate')){
				        		return false;
				        	}
				        },   
				        success:function(){  
				        	$('#dialog').dialog('close');
				        	$('#grid').datagrid('reload');
				        	$.messager.show({
				        		title:'提示',
				        		height:170,
				        		msg:'修改成功'
				        	});
				       }   
				   });			   			
				
		  	});
			
			$('#cancel').click(function(){
		    	$('#dialog').dialog('close');
		    });			
		});
	</script>
  </head>
  
  <body>
  	<table id="grid"></table>
  	
	<div id="dialog" class="easyui-dialog" closed=true resizable=false modal=true  style="width:450px;" >  	     	 
			<form id="myform" action="" method="post">
			<input id="confirmerId" type="hidden" name="flowCard.confirmer.id" value="">
			<input id="confFlag" type="hidden" name="flowCard.confFlag" value="">
		  		<table>	
		  			<tr>
		  				<td>流向单号</td>
		  				<td>
		  					<input id="flowCardId" type="text" name="flowCard.id" readonly="readonly" style="width:200px;">					
		  				</td>	  				 				
		  			</tr>
		  			<tr>
		  				<td>复审人人</td>
		  				<td>
		  					<input id="confirmerName" type="text" readonly="readonly" style="width:200px;">					
		  				</td>	  				 				
		  			</tr>
		  			<tr>
		  				<td>复审时间</td>
		  				<td>
		  					<input id="confDate" name="flowCard.confDate" value="<%=date %>" type="text" readonly="readonly" style="width:200px;">					
		  				</td>	  				 				
		  			</tr>		  					  					  	
		  			<tr>
		  				<td align="center" colspan="2">
		  					<a id="save" class="easyui-linkbutton">保存</a>
		  					<a id="cancel" class="easyui-linkbutton">取消</a>
		  				</td>
		  			</tr>
		  		</table>	
		  	</form>			  	
		  </div>  		  
  </body>
</html>
